//
//  YJMainTabBarController.swift
//  yuejian
//
//  Created by yanziye on 2017/9/28.
//  Copyright © 2017年 gyy. All rights reserved.
//

import UIKit

class trainingMainTabBarController: trainingTabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        setupTabBarController()
    }
    //设置所有的子控制器，定义子控制器的图标，标题等
    func setupTabBarController() {
       
        let trainingStoryBoard: UIStoryboard = UIStoryboard(name: "training", bundle: nil)
        let trainingNavgationController: UIViewController = trainingStoryBoard.instantiateViewController(withIdentifier: "trainingNav")
        
        let clubStoryBoard: UIStoryboard = UIStoryboard(name: "club", bundle: nil
        let clubNavgationController: UIViewController = clubStoryBoard.instantiateViewController(withIdentifier: "clubNav")
        
        let masterStoryBoard: UIStoryboard = UIStoryboard(name: "master", bundle: nil)
        let masterNavgationController: UIViewController = masterStoryBoard.instantiateViewController(withIdentifier: "masterNav")
        
        let pictureStoryBoard: UIStoryboard = UIStoryboard(name: "picture", bundle: nil)
        let pictureNavgationController: UIViewController = pictureStoryBoard.instantiateViewController(withIdentifier: "pictureNav")
      
        
        self.viewControllers = [trainingNavgationController,clubNavgationController,masterNavgationController,pictureNavgationController]
        
        
        let tabBarItemImages = ["first","second","fourth","third"]
        let tabBarItemTitles = ["培训","俱乐部","大师","晒图"]
        
        let tabBar = self.tabBar
        tabBar?.frame = CGRect(x: (tabBar?.frame.minX)!, y: (tabBar?.frame.minY)!, width: (tabBar?.frame.width)!, height: 63)
        var index : Int = 0
        
        // let tabBarItems =  self.tabBar.items as! [RDVTabBarItem
        
        for item  in self.tabBar.items as! [trainingTabBarItem]{
            
            let selectedimage = UIImage(named: "\(tabBarItemImages[index])"+"_select")
            let unselectedimage = UIImage(named: "\(tabBarItemImages[index])"+"_unselect")
            
            item.setFinishedSelectedImage(selectedimage, withFinishedUnselectedImage: unselectedimage)
            item.title = tabBarItemTitles[index]
            index += 1
            
        }
        
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}
